package com.ling.greedy.snake.game.ui.pages.game.widget

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Dialog
import com.ling.greedy.snake.game.ui.theme.BORDER_COLOR
import com.ling.greedy.snake.game.ui.theme.FONT_COLOR
import com.ling.greedy.snake.game.ui.theme.GAME_BG

/**
 * @author Ling
 * @date :2025/7/4 15:32
 */

@Composable
fun GameOverDialog(score : Int , onRestart : () -> Unit){
    Dialog(onDismissRequest = {}) {
        Column(
            modifier = Modifier.size(300.dp , 200.dp).background(GAME_BG , RoundedCornerShape(10.dp)).padding(15.dp),
            horizontalAlignment = Alignment.CenterHorizontally
        ) {
            Text("GAME OVER!" , fontSize = 20.sp , fontWeight = FontWeight.Bold , color = FONT_COLOR)
            Spacer(Modifier.weight(1f))
            Text("SCORE: $score" , color = FONT_COLOR)
            Spacer(Modifier.weight(1f))

            Box(
                modifier = Modifier
                    .fillMaxWidth()
                    .height(48.dp)
                    .border(width = 4.dp , shape = RoundedCornerShape(10.dp) , color = BORDER_COLOR)
                    .clip(RoundedCornerShape(10.dp))
                    .clickable{
                        onRestart.invoke()
                    }
            ){
                Text(text = "RESTART", Modifier.align(Alignment.Center) , color = FONT_COLOR)
            }
        }
    }
}